﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;
using LinFu.IoC;
namespace CoreEx.Wcf.Common.Implementation
{
    [PostProcessor]
    public class ServicePostProcessor : IPostProcessor
    {                
        public void PostProcess(IServiceRequestResult result)
        {
            if (result.ServiceType != typeof(ITypeResolver) && result.ServiceName != "ServiceContractTypes")
            {

                if (result.OriginalResult == null && result.ServiceType.IsServiceContract())
                {
                    result.ActualResult = result.Container.GetService<IChannelProxyFactory>().CreateChannelProxy(result.ServiceType);
                }
            }
        }
    }
}   